package com.whiteseason

import org.apache.spark.{SparkConf, SparkContext}

object wordcount {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setAppName("wordcount")
    val sc = new SparkContext(conf)
    val textFile = sc.textFile(args(0))
    val words = textFile.flatMap(x => x.split(" "))
    val counts = words.map(x=>(x,1)).reduceByKey(_+_)
    counts.saveAsTextFile(args(1))
    sc.stop()
  }
}
